package com.bit.demo.springioc.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("pro")
@Controller
@ResponseBody
public class PropertiesController {
    // 从配置文件中获取my.key的值
        @Value("${my.key}")
        private String myKey;
        @Value("${my.key2}")
        private boolean myKey2;

        @RequestMapping("get")
        public String getMyKey(){
                return myKey;
        }
        @PostConstruct
        public void init(){
            System.out.println("myKey2="+myKey2);
        }
}
